package com.neuedu.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.entity.EmploymentApplication;
import com.neuedu.entity.UmsStudent;
import com.neuedu.service.EmploymentApplicationService;
import com.neuedu.util.JwtUtil;
import com.neuedu.vo.ResultJson;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  就业申请表
 * </p>
 *
 * @author gaoqiang
 * @since 2025-09-09
 */
@RestController
@RequestMapping("/employmentApplication")
@Tag(name = "应聘申请表")
public class EmploymentApplicationController {
    @Resource
    EmploymentApplicationService employmentApplicationService;

    @PostMapping("/add")
    @Operation(summary = "添加新的申请")
    ResultJson<Boolean> add(EmploymentApplication employmentApplication,long login_id) {
        employmentApplication.setUserId(login_id);
        return ResultJson.success(employmentApplicationService.add(employmentApplication), "添加就业经历成功");
    }

    @PostMapping("/delete")
    @Operation(summary = "删除申请")
    ResultJson<Boolean> delete(long id) {
        return ResultJson.success(employmentApplicationService.delete(id),  "删除成功");
    }

    @PostMapping("/update")
    @Operation(summary = "保存当前修改的申请")
    ResultJson<Boolean> update(EmploymentApplication employmentApplication,long login_id) {
        return ResultJson.success(employmentApplicationService.update(employmentApplication), String.format("公司【%s】已保存！", StringUtils.isNoneBlank(employmentApplication.getCompanyName()) ? employmentApplication.getCompanyName() : "未命名" ));
    }


    @GetMapping("/list")
    @Operation(summary = "查询用户id对应的所有申请，一般是点进该网页查询")
    public ResultJson<List<EmploymentApplication>> list(Long login_id) {
        System.out.println(employmentApplicationService.checkByUserId(login_id));
        return ResultJson.success(employmentApplicationService.checkByUserId(login_id));
    }
}
